package com.system.around;
import java.lang.reflect.Method;
import org.springframework.aop.ThrowsAdvice;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


/**
 * Project			:myws
 * JDK version		:jdk1.6.0
 * Version          :1.0
 * Date             :2012-6-26
 * Author		    :陶尚明
 * Comments         :错误日志拦截类ExceptionAdvisor
 */
public class ExceptionAdvisor implements ThrowsAdvice {
	private final Log logger = LogFactory.getLog(getClass());
	
	public void afterThrowing(RuntimeException rx) {
		
	}
	
	/**
	 * 对未知异常的处理
	 */
	public void afterThrowing(Method method, Object[] args, Object target, Exception ex) throws Throwable {
		System.out.println("发现方法发生错误拉:"+method.getName());
		logger.error("发现方法发生错误拉:"+method.getName());
		method.getDeclaringClass().getPackage();
		System.out.println(ex.getMessage());
	}
	
	
	/**
	 * 对未知异常的处理
	 */
//	public void afterThrowing(Method method, Object[] args, Object target, NumberFormatException ex) throws Throwable {
//		System.out.println("发现方法发生错误拉:"+method.getName());
//	}
}
